package alittlepond.event;

import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Set;

public class NotifierAdapter implements Notifier{

	private Set<Notifiable> listeners;
	
	public NotifierAdapter() {
	//Is there no IdentityHashSet
//	listeners = new IdentityHashMap<Notifiable,Object>().keySet();
	listeners = Collections.newSetFromMap(new IdentityHashMap<Notifiable,Boolean>());
	}
	
	
	@Override
	public void addUpdateListener(Notifiable listener) {
		listeners.add(listener);
	}

	@Override
	public void updateAll() {
		for(Notifiable l : listeners){
			l.update();
		}
	}

	@Override
	public void removeUpdateListener(Notifiable listener) {
		listeners.remove(listener);
	}
	
	
}
